package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Constructor constructor = cls.getConstructor(String.class);
        Object obj = constructor.newInstance("张三");
        Method method = cls.getMethod("say", String.class);
        method.invoke(obj, "你好啊");


        Method method1 = cls.getMethod("say", String.class,int.class);
        method1.invoke(obj,"你好啊",2);


















    }
}
